package com.myz.rabbitmq.study2;

import com.myz.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

// 这是个工作线程，相当于
public class Worker02 {
    // 队列名称
    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception {
        Channel channer = RabbitMqUtils.getChannel();
        // recieve message
        DeliverCallback deliverCallback = (consumerTag,message) ->{
            System.out.println("接受的消息"+new String(message.getBody()));
        };
        // cancel message
        CancelCallback cancelCallback = (consumerTag) ->{
            System.out.println(consumerTag+"消息被取消,回调逻辑");
        };
        System.out.println("consumer3等待接收消息...");
        channer.basicConsume(QUEUE_NAME,true,deliverCallback,cancelCallback);
    }
}
